package com.kaibes.admin.site;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kaibes.core.base.util.ObjectUtils;
import com.kaibes.module.value.KeyValueService;
import com.kaibes.web.response.ResponseFactory;

@RestController
@RequestMapping("/sites")
public class SiteApi {
	
	@Autowired
	private KeyValueService service;
	@Autowired
    private SiteInfo siteInfo;

	@PutMapping
	public ResponseEntity<Object> put(@RequestBody SiteInfo data) {
		if (service.saveObject(data)) {
			ObjectUtils.copyProperties(data, siteInfo);
			return ResponseFactory.putSuccess("更新网站信息成功");
		} else {
			return ResponseFactory.putFailure("更新网站信息失败");
		}
	}
	
}
